from typing import Dict, Type
from app.agent.core import Agent, DatabaseAgent, FinanceAgent

class AgentFactory:
    """智能体工厂类"""
    
    # 注册的智能体类型
    _agent_registry: Dict[str, Type[Agent]] = {}
    
    @classmethod
    def register_agent(cls, name: str, agent_class: Type[Agent]):
        """注册智能体类型"""
        cls._agent_registry[name] = agent_class
        
    @classmethod
    def create_agent(cls, agent_type: str, **kwargs) -> Agent:
        """创建智能体实例"""
        if agent_type not in cls._agent_registry:
            raise ValueError(f"未知的智能体类型: {agent_type}")
            
        agent_class = cls._agent_registry[agent_type]
        return agent_class(**kwargs)
        
    @classmethod
    def list_available_agents(cls) -> list:
        """列出所有可用的智能体类型"""
        return list(cls._agent_registry.keys())

# 注册默认智能体
AgentFactory.register_agent("database", DatabaseAgent)
AgentFactory.register_agent("finance", FinanceAgent)